﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using JM.JCY.Proxy;
using JM.JCY.BusinessEntity;
using JM.JCY.Common;
using Microsoft.SharePoint;
namespace JM.JCY.SharePointComponent.News.ViewNewsDetail
{
    public partial class ViewNewsDetailUserControl : UserControl
    {
        public int _NewsId
        {
            set { ViewState["_NewsId"] = value; }
            get { return (int)ViewState["_NewsId"]; }
        }

        public string _category
        {
            set { ViewState["_category"] = value; }
            get { return (string)ViewState["_category"]; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["NewsId"] != null)
            {
                _NewsId = Int32.Parse(Request.QueryString["NewsId"]);

                using (NewsProxy newsProxy = new NewsProxy())
                {
                    NewsDataSet.T_AnnouncementDataTable annouceDT = newsProxy.GetNewsById(_NewsId);
                    this.lblSummary.Text = annouceDT[0].Summary;
                    this.imgPic.ImageUrl =SPContext.Current.Site.ServerRelativeUrl + annouceDT[0].ImageUrl;
                    imgOriginal.HRef = this.imgPic.ImageUrl;
          
                    this.lblCreatedDate.Text = annouceDT[0].CREATED_TIME.ToString(JCYConstant.Date_Format_CN);
                    this.lblSubject.Text = annouceDT[0].Subject;
                    _category = annouceDT[0].Category;
                    this.hfCategory.Value = _category;
                    this.hfId.Value = _NewsId.ToString();

                }
            }
        }
    }
}
